﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;

namespace TimeReporter
{
    public class TaskList : BindingList<TaskObject>
    {
        private static TaskList instance = new TaskList();

        //private BindingList<TaskObject> unfilteredCopy = new BindingList<TaskObject>();
        //private bool isFiltered;
                
        private TaskList() : base()
        {
            this.RaiseListChangedEvents = true;
        }

        public static TaskList GetInstance()
        {
            return instance;
        }

        

        protected override void InsertItem(int index, TaskObject item)
        {
            
            base.InsertItem(index, item);
        }
        /*
        public void filterByProject(string[] filter)
        {
            
            var dummy2 =
                from d in theTasks
                 where checkedListBox1.CheckedItems.Contains(d.Project)
                 select d;
            
            
            if (isFiltered == true)
            {
                instance = (TaskList)unfilteredCopy;


                
            }

            if (isFiltered == false)
            {
                isFiltered = true;
                
            }
            
            
        }
        
        public void unfilter()
        {
            isFiltered = false;
            instance = (TaskList)unfilteredCopy;
        }

        public List<string> getProjects()
        {
            List<string> theProjects = new List<string>();
            if (isFiltered == false)
            {
               
                theProjects =
                    (from d in instance
                     select d.Project).Distinct().ToList();

                
            }

            if (isFiltered == true)
            {
                
                theProjects =
                    (from d in unfilteredCopy
                     select d.Project).Distinct().ToList();

                
            }
            return theProjects;
        }
        */

       

       
     
      

     
    }
}
